home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 May / SGI IRIX 6.5 Applications 2004 May.iso / dist / java3d.idb / usr / demos / java / j3d / programs / examples / PickTest / CubeQA.java.z / CubeQA.java
Encoding:
Java Source  |  2003-08-08  |  3.8 KB  |  129 lines

  1. /*
  2.  *    @(#)CubeQA.java 1.9 02/04/01 15:03:40
  3.  *
  4.  * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  *
  10.  * - Redistributions of source code must retain the above copyright
  11.  *   notice, this list of conditions and the following disclaimer.
  12.  *
  13.  * - Redistribution in binary form must reproduce the above copyright
  14.  *   notice, this list of conditions and the following disclaimer in
  15.  *   the documentation and/or other materials provided with the
  16.  *   distribution.
  17.  *
  18.  * Neither the name of Sun Microsystems, Inc. or the names of
  19.  * contributors may be used to endorse or promote products derived
  20.  * from this software without specific prior written permission.
  21.  *
  22.  * This software is provided "AS IS," without a warranty of any
  23.  * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
  24.  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
  25.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
  26.  * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
  27.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  28.  * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
  29.  * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
  30.  * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
  31.  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
  32.  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
  33.  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  34.  *
  35.  * You acknowledge that Software is not designed,licensed or intended
  36.  * for use in the design, construction, operation or maintenance of
  37.  * any nuclear facility.
  38.  */
  39.  
  40. import javax.media.j3d.*;
  41. import javax.vecmath.*;
  42.  
  43. class CubeQA extends QuadArray {
  44.     CubeQA() {
  45.     super(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
  46.  
  47.  
  48.     Point3f verts[] = new Point3f[8];
  49.     Color3f colors[] = new Color3f[6];
  50.     
  51.     verts[0] = new Point3f(1.0f, 1.0f,  1.0f);
  52.     verts[1] = new Point3f(-1.0f, 1.0f, 1.0f);
  53.     verts[2] = new Point3f(-1.0f,-1.0f, 1.0f);
  54.     verts[3] = new Point3f( 1.0f,-1.0f, 1.0f);
  55.     verts[4] = new Point3f( 1.0f, 1.0f,-1.0f);
  56.     verts[5] = new Point3f( -1.0f, 1.0f,-1.0f);
  57.     verts[6] = new Point3f( -1.0f,-1.0f,-1.0f);
  58.     verts[7] = new Point3f( 1.0f,-1.0f,-1.0f);
  59.     
  60.     colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
  61.     colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
  62.     colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
  63.     colors[3] = new Color3f(1.0f, 1.0f, 0.0f);
  64.     colors[4] = new Color3f(1.0f, 0.0f, 1.0f);
  65.     colors[5] = new Color3f(0.0f, 1.0f, 1.0f);
  66.     
  67.     Point3f pnts[] = new Point3f[24];
  68.     Color3f clrs[] = new Color3f[24];
  69.  
  70.     pnts[0] = verts[0];
  71.     clrs[0] = colors[0];
  72.     pnts[1] = verts[3];
  73.     clrs[1] = colors[0];
  74.     pnts[2] = verts[7];
  75.     clrs[2] = colors[0];
  76.     pnts[3] = verts[4];
  77.     clrs[3] = colors[0];
  78.  
  79.     pnts[4] = verts[1];
  80.     clrs[4] = colors[1];
  81.     pnts[5] = verts[5];
  82.     clrs[5] = colors[1];
  83.     pnts[6] = verts[6];
  84.     clrs[6] = colors[1];
  85.     pnts[7] = verts[2];
  86.     clrs[7] = colors[1];
  87.  
  88.     pnts[8]  = verts[0];
  89.     clrs[8]  = colors[2];
  90.     pnts[9]  = verts[4];
  91.     clrs[9]  = colors[2];
  92.     pnts[10] = verts[5];
  93.     clrs[10] = colors[2];
  94.     pnts[11] = verts[1];
  95.     clrs[11] = colors[2];
  96.  
  97.     pnts[12] = verts[3];
  98.     clrs[12] = colors[3];
  99.     pnts[13] = verts[2];
  100.     clrs[13] = colors[3];
  101.     pnts[14] = verts[6];
  102.     clrs[14] = colors[3];
  103.     pnts[15] = verts[7];
  104.     clrs[15] = colors[3];
  105.  
  106.     pnts[16] = verts[0];
  107.     clrs[16] = colors[4];
  108.     pnts[17] = verts[1];
  109.     clrs[17] = colors[4];
  110.     pnts[18] = verts[2];
  111.     clrs[18] = colors[4];
  112.     pnts[19] = verts[3];
  113.     clrs[19] = colors[4];
  114.  
  115.     pnts[20] = verts[7];
  116.     clrs[20] = colors[5];
  117.     pnts[21] = verts[6];
  118.     clrs[21] = colors[5];
  119.     pnts[22] = verts[5];
  120.     clrs[22] = colors[5];
  121.     pnts[23] = verts[4];
  122.     clrs[23] = colors[5];
  123.  
  124.  
  125.     setCoordinates(0, pnts);
  126.     setColors(0, clrs);
  127.     }
  128. }
  129.